import 'package:flutter_screenutil/screenutil.dart';
import 'package:flutter/material.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/TwoLabelItem.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/LeftLabelInputItem.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/NavigationBar.dart';
import 'package:keyboard_avoider/keyboard_avoider.dart';
import 'package:heyangkuaidai/DemonStrateModule/LoanRepayConfirmPage.dart';
class LoanDetailPage extends StatefulWidget {
  @override
  _LoanDetailPageState createState() => _LoanDetailPageState();
}

class _LoanDetailPageState extends State<LoanDetailPage> {
  String money;
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 375, height: 667, allowFontScaling: true);
    final ScrollController _scrollController = ScrollController();
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Column(
        children: [
          SizedBox(height: MediaQuery.of(context).padding.top,),
          NavigationBar(false, title: "借款详情",),
          Container(
              width: ScreenUtil.screenWidth,
              height: ScreenUtil.screenHeight-ScreenUtil().setWidth(169)-MediaQuery.of(context).padding.top,
              child:KeyboardAvoider(
                autoScroll: true,
                child: ListView(
                  controller: _scrollController,
                  padding: EdgeInsets.only(top: 0),
                  children: [
                    Stack(
                      children: [
                        Container(
                          width:ScreenUtil.screenWidth,
                          height: ScreenUtil().setWidth(136),
                          child: Image.asset("sources/yy/loanDetailTop.png",),
                        ),
                        Positioned(
                            left: ScreenUtil().setWidth(15),
                            top: ScreenUtil().setWidth(24),
                            child: Container(
                              width: ScreenUtil().setWidth(345),
                              height: ScreenUtil().setWidth(100),
                              color:Colors.white,
                              child: Row(
                                children: [
                                  SizedBox(width: ScreenUtil().setWidth(43),),
                                  Column(
                                    children: [
                                      SizedBox(height: ScreenUtil().setWidth(27),),
                                      Container(
                                        width: ScreenUtil().setWidth(110),
                                        child:Text("借款金额（元）",style: TextStyle(fontSize: ScreenUtil().setSp(12),color: Color(0xff999999)),textAlign: TextAlign.center,),
                                      ),
                                      SizedBox(height: ScreenUtil().setWidth(5),),
                                      Container(
                                        width: ScreenUtil().setWidth(110),
                                        child:Text("¥80000.00",style: TextStyle(fontSize: ScreenUtil().setSp(20),),textAlign: TextAlign.center,),
                                      ),
                                    ],
                                  ),
                                  SizedBox(
                                    width: ScreenUtil().setWidth(20),
                                  ),
                                  Container(
                                    width: ScreenUtil().setWidth(1),
                                    height: ScreenUtil().setWidth(30),
                                    color: Color(0xffEBEBEB),
                                  ),
                                  SizedBox(
                                    width: ScreenUtil().setWidth(20),
                                  ),
                                  Column(
                                    children: [
                                      SizedBox(height: ScreenUtil().setWidth(27),),
                                      Container(
                                        width: ScreenUtil().setWidth(110),
                                        child:Text("借款余额（元）",style: TextStyle(fontSize: ScreenUtil().setSp(12),color: Color(0xff999999)),textAlign: TextAlign.center,),
                                      ),
                                      SizedBox(height: ScreenUtil().setWidth(5),),
                                      Container(
                                        width: ScreenUtil().setWidth(110),
                                        child:Text("¥60000.00",style: TextStyle(fontSize: ScreenUtil().setSp(20),),textAlign: TextAlign.center,),
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            )
                        ),
                      ],
                    ),
                    TwoLabelItem(title:"贷款账号" ,hitText:"3401 **** **** *391 9 " ,),
                    TwoLabelItem(title:"还款账号", hitText: "3401 **** **** *391 9",),
                    TwoLabelItem(title:"年利率", hitText: "4.65%",),
                    TwoLabelItem(title:"借款日期", hitText: "2021-05-01",),
                    TwoLabelItem(title:"到期日期", hitText: "2022-04-30",),
                    TwoLabelItem(title:"应还利息", hitText: "￥31.50",),
                    TwoLabelItem(title:"借款状态", hitText: "全额发放",),
                    TwoLabelItem(title:"发放网点", hitText: "益阳农商银行",),
                    LeftLabelInputItem(title: "还款金额",hitText: "请输入还款金额",finishCallback: (text){
                        money =text;
                    },),

                  ],
                 ) ,
                ),
          ) ,
          SizedBox(height: ScreenUtil().setWidth(23),),
          InkWell(
            onTap: (){
              if(money.isEmpty){
                return;
              }
                 Navigator.push(
                  context,
                  new MaterialPageRoute(
                    builder: (context) => new LoanRepayConfirmPage(money: money,),
                  ),
                );
            },
            child: Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4),
                  color:Color(0xff41A5EE),
                ),
                width: ScreenUtil().setWidth(347),
                height: ScreenUtil().setWidth(44),
                child:Center(
                  child: Text("还款",style: TextStyle(fontSize: ScreenUtil().setSp(17),color: Colors.white),textAlign: TextAlign.center,),
                )
            ) ,
          )
        ],
      ),
    );
  }
}
